import Vue from 'vue'
import VueRouter from 'vue-router'
import './lib/repeatRoute'
import route from './lib/menuTransformRoute'
import staticRouter from './staticRouter'
Vue.use(VueRouter)

const routes = [
  ...route,
  ...staticRouter,
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404.vue')
  }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

console.log(routes, 111)

// const childrenPath = ['/app1', '/app2']
// router.beforeEach((to, from, next) => {
//   if (to.name) {
//     // 有 name 属性，说明是主应用的路由
//     next()
//   }
//   if (childrenPath.some((item) => to.path.includes(item))) {
//     next()
//   }
//   next({ name: '404' })
// })

export default router
